<template>
    <a-table class="ant-table-striped" :columns="columns" size="small" :data-source="data" :pagination="false">
        <template #bodyCell="{ column, record }">
            <template v-if="column.key === 'action'">
                <a-button type="primary" v-if="record.draft !== null" size="small"
                    @click.stop="emit('LookAtCode', record)">查看
                </a-button>
            </template>
            <template v-if="column.key === 'submitTime'">
                {{ record.updateTime && dayjs(record.submitTime).toNow() }}
            </template>
            <template v-else-if="column.key === 'status'">
                <a-tag v-if="!record.draft" color="default">未提交</a-tag>
                <a-tag v-else-if="record.draft && !record.total" color="orange">待评分</a-tag>
                <a-tag v-else-if="record.draft && record.total" color="green">已完成</a-tag>
            </template>
        </template>
    </a-table>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import Admin from '@/apis/admin'
import dayjs from 'dayjs';

const emit = defineEmits(['LookAtCode']);
const props = defineProps({
    id: String
});

const columns = [
    { title: '姓名', dataIndex: 'nickname', key: 'nickname', },
    { title: '状态', dataIndex: 'status', key: 'status', },
    { title: '提交时间', key: 'submitTime', dataIndex: 'submitTime', },
    { title: '规范性', dataIndex: 'inspectA', key: 'inspectA', },
    { title: '严谨性', dataIndex: 'inspectB', key: 'inspectB', },
    { title: '复用性', key: 'inspectC', dataIndex: 'inspectC', },
    { title: '还原度', dataIndex: 'inspectD', key: 'inspectD', },
    { title: '整洁度', dataIndex: 'inspectE', key: 'inspectE', },
    { title: '总分', key: 'total', dataIndex: 'total', },
    { title: '操作', width: '60px', key: 'action', },
];

const data = ref<AdminInspectTable[]>([]);

onMounted(() => {
    Admin.GetInspect({ id: props.id }).then((res: any) => {
        data.value = res;
    });
});



</script>
<style lang="less" scoped>

</style>